//
//  MovieListTableViewCell.m
//  UI_TabBarTest1(豆瓣)
//
//  Created by dllo on 16/6/25.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "MovieListTableViewCell.h"
#define kWidth self.frame.size.width
#define kHeight self.frame.size.height
#import "Movie.h"

@interface MovieListTableViewCell ()

@property (nonatomic,retain) UIImageView *backGroundImageView;
@property (nonatomic,retain) UIImageView *movieImageView;
@property (nonatomic,retain) UILabel *movieLabel;

@end


@implementation MovieListTableViewCell

-(void)dealloc{
    [_movieImageView release];
    [_movieLabel release];
    [_movie release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backGroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_eventlistcell"]];
        
        [self.contentView addSubview:self.backGroundImageView];
        
        self.movieImageView = [[UIImageView alloc] init];
        [self.backGroundImageView addSubview:self.movieImageView];
        [_movieImageView release];
        
        self.movieLabel = [[UILabel alloc] init];
        [self.backGroundImageView addSubview:self.movieLabel];
        [_movieLabel release];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
   
    self.backGroundImageView.frame = CGRectMake(0, 15, kWidth, kHeight - 30);
    
    self.movieImageView.frame = CGRectMake(10, 5, kWidth * 0.3, kHeight - 40);
    NSURL *url = [NSURL URLWithString:self.movie.pic_url];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *image = [UIImage imageWithData:data];
    self.movieImageView.image = image;
    
    self.movieLabel.frame = CGRectMake(kWidth * 0.3 + 30, 5, kWidth * 0.6, kHeight - 40);
    self.movieLabel.text = self.movie.movieName;
    self.movieLabel.font = [UIFont systemFontOfSize:30.0];

}

@end
